<template>
	<view class="container">

		<uni-section title="我的房屋" type="line">
			<uni-card :is-shadow="false" v-for="(item, index) in infofindall">

				<view @click="housinfo(item)">
					<view class="flex-row wrapper">
						<!--     <u-button class="button" shape="circle" size="mini">默认</u-button> -->
						<view class="u-line-1 text">{{item.communityName}}</view>
						<u-button class="button-two" shape="circle" size="mini">{{item.auditState}}</u-button>
					</view>
					<u-line class="line" margin="15rpx 15rpx 20rpx 12rpx"></u-line>
					<view class="flex-row wrapper-two">
						<view class="u-line-1 text-two">房间号:</view>
						<view class="u-line-1 text-three">
							0{{item.howMany}}栋{{item.cellNumber}}单元{{item.howFloor}}楼{{item.howPortal}}号</view>
					</view>
					<view class="flex-row wrapper-three">
						<view class="u-line-1 text-four">业主:</view>
						<view class="u-line-1 text-five">小黑</view>
					</view>
					<view class="flex-row wrapper-four">
						<view class="u-line-1 text-six">房屋状态:</view>
						<view class="u-line-1 text-seven">{{item.state}}</view>
					</view>
				</view>
			</uni-card>
		</uni-section>


		<u-button @click="addhouse()" class="button1">
			+添加房屋
		</u-button>



	</view>
</template>

<script>
	import request from '../../../request.js'
	let houseinfo = localStorage.getItem("houseinfo") ?
		JSON.parse(localStorage.getItem("houseinfo")) :
		null;
	let appUserInfo = localStorage.getItem("appUserInfo") ?
		JSON.parse(localStorage.getItem("appUserInfo")) :
		null;
	let userId = localStorage.getItem("userId") ?
		JSON.parse(localStorage.getItem("userId")) :
		null;
	export default {
		data() {
			return {
				infofindall: []

			};

		},
		methods: {
			addhouse() {
				uni.navigateTo({
					url: './housinginformation'
				})

			},
			housinfo(item) {

				const aa = item
				if (item.auditState == '认证中') {
					localStorage.setItem("hinfo", JSON.stringify(aa))
					uni.navigateTo({

						url: './propertyreview'
					})

				} else if (item.auditState == '认证成功') {

					localStorage.setItem("hinfo", JSON.stringify(aa))
					uni.navigateTo({

						url: './authenticationsuccess'
					})
				}
			},
			houseFind() {
				console.log(userId)
				request({
					url: '/housingestate/portal/appFindMyhouse/' + userId,
					method: 'POST',
					success: (res) => {
						console.log(res)
						if (res.data.code == 20000) {
							console.log(res.data.data)
							this.infofindall = res.data.data.myhouseinfo
							console.log(this.infofindall)
						} else {
							uni.showToast({
								title: '查询失败,无此信息',
								icon: 'error'
							})
						}
					}
				})
			}


		},
		onLoad() {
			this.houseFind()
		}
	}
</script>

<style lang="scss">
	/** 全局样式-开始,建议放在公共css样式文件中,比如common.css 或app.vue文件 */
	.button1 {
		width: 694rpx;
		height: 90rpx;
		display: block;
		margin-right: auto;
		margin-left: auto;
		font-size: 36rpx;
		background: #006eff;
		color: #ffffff;
	}

	html,
	body {
		margin: 0;
		width: 100%;
		height: 100%;
		font-size: 16px
	}

	view,
	text,
	image {
		position: relative;
		box-sizing: border-box;
		flex-shrink: 0;
	}

	.flex-col {
		display: flex;
		align-items: flex-start;
		flex-direction: column;
	}

	.flex-row {
		display: flex;
		align-items: flex-start;
	}

	.flex-col .flex-row {
		width: 100%
	}

	/** 全局样式-结束*/
	.button {
		background: #006eff;
		color: #ffffff;
	}

	.button-two {
		background: rgba(213, 246, 227, 1);
		color: rgba(67, 214, 127, 1);
		width: 260rpx;
		height: 50rpx;
	}

	.homepage {
		height: 1334rpx;
		padding: 96rpx 0rpx 0rpx 89rpx;

		.wrapper {
			width: 423rpx;
			justify-content: space-between;
			margin-bottom: 17rpx;

			.button {
				width: 50rpx;
				height: 10rpx;
				background: #006eff;
				color: #ffffff;
			}

			.text {
				width: 210rpx;
				margin-top: 4rpx;
				font-size: 36rpx;

			}

			.button-two {
				width: 60rpx;
				height: 28rpx;
				background: #268497;
				color: #ffffff;
			}
		}

		.line {
			width: 397rpx;
		}

		.wrapper-two {
			width: 396rpx;
			justify-content: space-between;
			margin: 0rpx 0rpx 10rpx 23rpx;

			.text-two {
				width: 100rpx;
			}

			.text-three {
				width: 283rpx;
				position: absolute;
				left: 50rpx;

			}
		}

		.wrapper-three {
			width: 396rpx;
			justify-content: space-between;
			margin: 0rpx 0rpx 10rpx 23rpx;

			.text-four {
				width: 50rpx;
			}

			.text-five {
				width: 283rpx;
			}
		}

		.wrapper-four {
			width: 396rpx;
			justify-content: space-between;
			margin-left: 23rpx;

			.text-six {
				width: 72rpx;
			}

			.text-seven {
				width: 283rpx;
			}
		}
	}
</style>
